var indexCagegory = {
	getData : function() {
		$.ajax({
			async : false,
			dataType : "json",
			type : "post",
			url : "/app/category!getAllFirstCategoryAndCount",
			success : function(data) {
				backUrl.addCookie(data.state);
				if ('success' == data.state) {
					var fc = $(".sz_2016_xmfl");
					var content = "";
					var scList = data.msg;
					fc.empty();
					if (scList.length > 0 && scList != null) {
						var num = 0;
						for ( var int = 0; int < scList.length; int++) {
							var v = scList[int];
							var name = v.second_category_name;
							var count = v.count;

							var className = "";
							var imgName = "";
							switch (num) {
							case 0:
								className = "sz_yw_tilel_LV";
								imgName = "2016xm.png";
								break;
							case 1:
								className = "sz_yw_tilel_SL";
								imgName = "2016yhwh.png";
								break;
							case 2:
								className = "sz_yw_tilel_QL";
								imgName = "2016fz.png";
								break;
							case 3:
								className = "sz_yw_tilel_JH";
								imgName = "2016qt.png";
								break;
							}

							// content += "<div class='sz_yw_tilel sz_yw_tilel1'
							// onClick='jumpCagetory(" + int + ")'
							// style='cursor:hand'><div class='" + className +
							// "'><h2><img src='/img/" + imgName
							// + "' />" + name + "（" + count +
							// "）</h2></div></div>";
							content += "<div class='sz_yw_tilel sz_yw_tilel1' onClick='jumpCagetory(" + int
									+ ")' style='cursor:hand'><div class='" + className + "'><h2><img src='/img/"
									+ imgName + "' /><a href='javascript:void()'>" + name + "（" + count
									+ "）</a></h2></div></div>";

							num++;
							if (num >= 4) {
								num = 0;
							}
						}
					} else {
						content = "<div class='sz_yw_tilel sz_yw_tilel1'><div class='sz_yw_tilel_SL'>"
								+ "<h2><a href='javascript:void()'>暂无数据</a></h2></div></div>";
					}
					fc.append(content);
				} else if (data.state == "error") {
					errorAlert(data.msg);
				}
			}
		});
	}
};
function jumpCagetory(num) {
	window.open("/app/project!jumpProjectList?type=" + num);
}
var indexTime = {
	getData : function() {
		$.ajax({
			async : false,
			dataType : "json",
			type : "post",
			url : "/app/project!getProjectCountByTime",
			success : function(data) {
				backUrl.addCookie(data.state);
				if ('success' == data.state) {
					var fc = $(".sz_2016_xmjd");
					var content = "";
					var fcList = data.msg;
					fc.empty();
					if (fcList.length != 0 && fcList != null) {
						for ( var int = 0; int < fcList.length; int++) {
							var v = fcList[int];
							var num = int + 1;

							var className = "";
							var timeName = "";
							var imgName = "";
							switch (int) {
							case 0:
								className = "sz_yw_tilel_LV";
								timeName = "储备项目";
								imgName = "2016zj.png";
								break;
							case 1:
								className = "sz_yw_tilel_SL";
								timeName = "在建项目";
								imgName = "2016ls.png";
								break;
							case 2:
								className = "sz_yw_tilel_QL";
								timeName = "完成项目";
								imgName = "2016yq.png";
								break;
							}

							// content += "<div class='sz_yw_tilel'
							// onClick='jumpTime(" + num
							// + ")' style='cursor:hand'><div class='" +
							// className + "'><h2><img src='/img/"
							// + imgName + "' />" + timeName + "（" + v +
							// "）</h2></div></div>";
							content += "<div class='sz_yw_tilel' onClick='jumpTime(" + num
									+ ")' style='cursor:hand'><div class='" + className + "'><h2><img src='/img/"
									+ imgName + "' /><a href='javascript:void()'>" + timeName + "（" + v
									+ "）</a></h2></div></div>";
						}
					} else {
						content = "<div class='sz_yw_tilel'><div class='sz_yw_tilel_SL'><h2>"
								+ "<a href='javascript:void()'>暂无数据</a></h2></div></div>";
					}
					fc.append(content);
				} else if (data.state == "error") {
					errorAlert(data.msg);
				}
			}
		});
	}
};
function jumpTime(num) {
	window.open("/app/project!jumpProjectList?plan=" + num);
}
function changeType(type) {
	$(".sz_2016_xmf_tab").find("a").eq(type).addClass("sz_2016_xmfl_xz").siblings().removeClass("sz_2016_xmfl_xz");
	switch (type) {
	case 0:
		$(".sz_2016_xmfl").hide();
		$(".moreCategory").hide();
		$(".sz_2016_xmjd").show();
		indexTime.getData();
		break;
	case 1:
		$(".sz_2016_xmjd").hide();
		$(".moreCategory").show();
		$(".sz_2016_xmfl").show();
		indexCagegory.getData();
		break;
	}
}
var onloadIndex = {
	onload : function() {
		// indexCagegory.getData();
		indexTime.getData();
		$("#generalSearchA").click(function() {
			var name = $("#generalSearchTxt").val();
			if (checkSC(name)) {
				errorAlert("项目名称不能包含特殊符号！<br>如:<br>英文模式的： ! $ ( ) : ; ? ' \" <br>中英文模式的： / \\ + = @ # & *");
			} else {
				name = encodeURI(encodeURI(name));
				window.open("/app/project!jumpProjectNameSearch?projectName=" + name);
			}
		});
	}
};